<template>
  <div class="newVs">
    <div class="mask"></div>
    <div class="new_vs">
      <div class="vs-top">
        <p>新建资料（店铺盘点）</p>
        <i class="el-icon-close" @click="closeNewClerk"></i>
      </div>
      <div class="vs-info">
        <div class="info">
          <p>盘点日期</p>
          <el-date-picker
            v-model="checkTime"
            type="date"
            value-format="yyyy-MM-dd HH:mm:ss"
          ></el-date-picker>
          <p>单号</p>
          <el-input v-model="receiptsNumber"></el-input>
          <p>款号</p>
          <el-input v-model="kindsNumber"></el-input>
          <p>店铺</p>
          <el-input v-model="shopName" disabled></el-input>
          <p>类别</p>
          <el-select v-model="type">
            <el-option
              v-for="item in typeList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            ></el-option>
          </el-select>
        </div>
        <div class="info">
          <p>盘点序号</p>
          <el-input v-model="sequence" disabled></el-input>
          <!-- <p>店铺编号</p>
          <el-input v-model="shopNo" disabled></el-input> -->
          <p>客户编号</p>
          <el-select
            :disabled="Dis"
            style="width: 160px"
            v-model="customerNo"
            placeholder="请选择"
          >
            <el-option
              v-for="item in customerList"
              :key="item.value + Math.random()"
              :label="item.value"
              :value="item.value"
            >
              <span style="float: left">{{ item.value }}</span>
              <span style="float: right">{{ item.value1 }}</span>
            </el-option>
          </el-select>
          <p>售价</p>
          <el-input v-model="onePrice"></el-input>
          <p>实收单价</p>
          <el-input v-model="actualPayment"></el-input>
        </div>

        <el-table
          border
          :data="codeData"
          id="codeTable"
          class="tb-edit"
          style="width: 100%; margin-bottom: 15px"
          max-height="148px"
          @cell-click="cellClick"
          :header-cell-style="{
            background: '#f4f4f4',
            padding: 0,
            height: '40px'
          }"
          :cell-style="{ padding: 0, height: '36px' }"
        >
          <el-table-column :label="header" width="150"></el-table-column>
          <el-table-column
            prop="colorName"
            label="颜色"
            width="100"
          ></el-table-column>

          <template v-for="i in sizeList">
            <el-table-column :prop="i" :label="i" :key="i + Math.random()">
              <template slot-scope="scope">
                <el-input
                  size="small"
                  v-model="scope.row[i]"
                  @blur="
                    handleInputBlurResult($event, {
                      index: scope.$index,
                      key: i,
                      result: scope.row[i]
                    })
                  "
                  @keyup.enter.native="inpEnter"
                ></el-input>
                <!-- <span style="display:none;">{{scope.row[i]}}</span> -->
              </template>
            </el-table-column>
          </template>

          <!-- <template v-for="col in sizeList">
            <el-table-column
            :key="col+Math.random()"
            :prop="col"
            :label="col">
            <template slot-scope="scope">
              <el-input size="small" 
                class="innerInp"
                v-model="scope.row[col]" 
                @blur="handleClick($event,{index:scope.$index,key:col,result:scope.row[col]})" 
                @keyup.enter.native="inpEnter">
              </el-input>
            </template>
          </el-table-column>
          </template> -->
        </el-table>

        <div class="barcode">
          <p>条码扫描</p>
          <el-switch
            v-model="isBarcode"
            active-color="#409EFF"
            inactive-color="#C0C4CC"
          ></el-switch>
        </div>

        <div class="enterBarcode">
          <el-input
            id="input"
            ref="barcodeInput"
            v-model="barcode"
            placeholder="扫描/输入货号或款号，输完按回车"
            @keyup.enter.native="barcodeEnter($event)"
          ></el-input>
          <p style="margin: 15px 0 0 5px">合计：{{ howMany }}</p>
        </div>

        <el-table
          height="210px"
          :data="barcodeData"
          style="width: 100%"
          :header-cell-style="{
            background: '#f4f4f4',
            padding: 0,
            height: '40px'
          }"
          :cell-style="{ padding: 0, height: '36px' }"
        >
          <el-table-column
            prop="kindsNumber"
            label="款号"
            width="250"
          ></el-table-column>
          <el-table-column prop="colorName" label="颜色"></el-table-column>
          <el-table-column prop="sizeNo" label="尺码编号"></el-table-column>
          <el-table-column
            prop="sum"
            label="数量"
            width="100"
          ></el-table-column>
          <el-table-column
            prop="onePrice"
            label="售价"
            width="100"
          ></el-table-column>
          <el-table-column prop="" label="折数" width="60"></el-table-column>
          <el-table-column
            prop="onePrice"
            label="单价"
            width="100"
          ></el-table-column>
          <el-table-column prop="" label="金额" width="100"></el-table-column>
          <el-table-column prop="commodityName" label="品名"></el-table-column>
          <el-table-column prop="" label="品牌"></el-table-column>
          <el-table-column prop="" label="录入时间"></el-table-column>
        </el-table>
      </div>

      <div class="vs-btn">
        <el-button @click="closeNewClerk">取消</el-button>
        <el-button @click="saveNew" plain type="primary">保存</el-button>
        <el-button @click="continueInput" type="primary">继续录入</el-button>
      </div>

      <!-- F7弹出框 -->
      <div class="popup" :style="{ display: showPopup }">
        <div class="popup_t">
          <p>输入扫描数量</p>
          <i @click="closePopup" class="el-icon-close"></i>
        </div>
        <div class="popup_c">
          <p>请输入扫描数量</p>
          <p>如果不输入则扫描数量为1</p>
          <input
            type="text"
            class="popup_button"
            v-model="scanNum"
            @keyup.enter="
              () => {
                this.showPopup = 'none'
              }
            "
          />
        </div>

        <div class="popup_b">
          <el-button @click="closePopup">取消</el-button>
          <el-button
            type="primary"
            @click="
              () => {
                this.showPopup = 'none'
              }
            "
            >确定</el-button
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { orderBuild, orderQuery } from '../../../../network/manufacturerOrder'
import { getKindsNumberList } from '../../../../network/artNo'
import { getBarCode } from '../../../../network/manufacturer'

import exportMethods from '../../../../components/mixins/exportMethods'
import today from '../../../../components/mixins/today'
import enterUp from '../../../../components/mixins/enterUp'
import { postData, getShop } from '../../../../network/shop'
import { getClient } from '../../../../network/client'
export default {
  mixins: [today, enterUp],
  created() {
    console.log(document.cookie.match(RegExp('jxUser' + '=([^;]+)'))[1])
    this.time = this.getNowTime()
    getShop().then((res) => {
      console.log(res)
      for (let a of [res.data.data]) {
        this.shopNo = a.no
        this.shopName = a.name
        localStorage.setItem('sdNo', a.no)
      }
    })
    getClient().then((res) => {
      console.log(res.data)
      res.data.data.forEach((e) => {
        this.customerList.push({
          value: e.no,
          label: e.name,
          value1: e.name,
          value2: e.id
        })
      })
      for (let i of this.customerList) {
        if (i.label == this.operator) {
          this.customerNo = i.value
          // this.Dis = true
          break
        }
      }
    })
  },
  props: {
    flag: {
      type: Boolean,
      default: false
    },
    sequence1: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      howMany: '',
      Dis: true,
      customerList: [],
      customerNo: '',
      operator: document.cookie.match(RegExp('jxUser' + '=([^;]+)'))[1],
      time: '',
      // 条码规律详情
      manufacturerBarCode: {},
      // 品牌公司
      brandedCompany: '',
      // 尺码
      knSize: '',
      knSizeList: [],

      showPopup: 'none',

      checkTime: this.searchDateWithHour(),
      receiptsNumber: '',
      kindsNumber: '',
      shopName: '',
      type: '',
      typeList: [
        { label: '盘点', value: '盘点' },
        { label: '盘差', value: '盘差' }
      ],
      sequence: '',
      shopNo: '',
      onePrice: '',
      actualPayment: '',

      header: '',
      sizeList: [''],
      codeData: [],
      isBarcode: false,
      barcode: '',

      barcodeData: [],
      tmpBarcodeData: [],

      tmpData: {},
      scanNum: 1,
      beforeScanNum: 1
    }
  },
  watch: {
    barcode(a, b) {
      if (a != undefined) {
        this.barcode = a.toUpperCase().trim()
      }
    },
    kindsNumber(a, b) {
      if (a != undefined) {
        this.kindsNumber = a.toUpperCase().trim()
      }
    },
    flag(a, b) {
      if (a && this.inputSequence) {
        orderQuery({ orderSalesSequence: this.inputSequence }).then((res) => {
          if (res.data.code == 200) {
            this.receiptsNumber =
              res.data.data[this.inputSequence].receiptsNumber
            this.remark = res.data.data[this.inputSequence].remark
            this.barcodeData =
              res.data.data[this.inputSequence].manufacturerOrderInfoOneVOList
            this.checkTime1 = this.barcodeData[0].orderTime
            this.checkTime2 = this.barcodeData[0].prepayTime
            this.manufacturer = this.barcodeData[0].manufacturerNo
            this.additional = this.barcodeData[0].isAdd == 1 ? true : false
            this.barcodeData.forEach((e) => {
              e.sum = e.number
            })
          }
        })
      }
    },
    sequence1(a, b) {
      console.log(a)
      this.sequence = a
    }
  },
  methods: {
    closeNewClerk() {
      this.header = ''
      this.receiptsNumber = ''
      ;(this.cooperateWay = '配货'), (this.inputSequence = '')
      this.commodityName = ''
      this.onePrice = ''
      this.remark = ''
      this.isBarcode = false
      this.additional = false
      this.barcode = ''
      this.codeData = []
      this.barcodeData = []
      this.howMany = ''
      this.$emit('closeNew')
    },
    sibling(e) {
      let s = []
      let pp = e.parentNode.parentNode.children
      for (let j = 0; j < pp.length; j++) {
        let p = pp[j].children
        for (let i = 0, pl = p.length; i < pl; i++) {
          if (p[i] !== e) s.push(p[i])
        }
      }
      return s
    },
    // 输入货号后，颜色，尺码赋值
    csAssignment(str) {
      // 货号里提取色号，色号获取颜色
      // styleColor款色， 色尺colorSize
      let colorSize = str.slice(this.manufacturerBarCode.styleNumber).split('-')
      let tmpLen = 0
      if (this.manufacturerBarCode.styleColorSize) {
        // 型尺色

        if (this.manufacturerBarCode.styleColor) {
          // 款号与尺码之间有 -

          if (this.manufacturerBarCode.colorSize) {
            // 色号与尺码之间有 -        MCC-A0001-7-001   ["", "7", "001"]
            this.knSize = colorSize[1]
            this.colorNo = colorSize[2]
          } else {
            // 色号与尺码之间没有 -        MCC-A0001-7001    ["", "7001"]
            tmpLen = colorSize[1].length
            this.knSize = colorSize[1].slice(
              0,
              tmpLen - this.manufacturerBarCode.colorNumber
            )
            this.colorNo = colorSize[1].slice(
              tmpLen - this.manufacturerBarCode.colorNumber
            )
          }
        } else {
          // 款号与尺码之间没有 -

          if (this.manufacturerBarCode.colorSize) {
            // 色号与尺码之间有 -      MCC-A00017-001    ["7", "001"]
            this.knSize = colorSize[0]
            this.colorNo = colorSize[1]
          } else {
            // 色号与尺码之间没有 -     MCC-A00017001    ["7001"]
            tmpLen = colorSize[1].length
            this.knSize = colorSize[0].slice(
              0,
              tmpLen - this.manufacturerBarCode.colorNumber
            )
            this.colorNo = colorSize[0].slice(
              tmpLen - this.manufacturerBarCode.colorNumber
            )
          }
        }
      } else {
        // 型色尺

        if (this.manufacturerBarCode.styleColor) {
          // 款号与颜色之间有 -

          if (this.manufacturerBarCode.colorSize) {
            // 色号与尺码之间有 -     MCC-A0001-001-7   ["", "001", "7"]
            this.colorNo = colorSize[1]
            this.knSize = colorSize[2]
          } else {
            // 色号与尺码之间没有 -    MCC-A0001-0017   ["", "0017"]
            tmpLen = colorSize[1].length
            this.colorNo = colorSize[1].slice(
              0,
              this.manufacturerBarCode.colorNumber
            )
            this.knSize = colorSize[1].slice(
              this.manufacturerBarCode.colorNumber
            )
          }
        } else {
          // 款号与颜色之间没有 -

          if (this.manufacturerBarCode.colorSize) {
            // 色号与尺码之间有 -      MCC-A0001001-7      ["001", "7"]
            this.colorNo = colorSize[0]
            this.knSize = colorSize[1]
          } else {
            // 色号与尺码之间没有 -      MCC-A00010017     ["0017"]
            tmpLen = colorSize[1].length
            this.colorNo = colorSize[0].slice(
              0,
              this.manufacturerBarCode.colorNumber
            )
            this.knSize = colorSize[0].slice(
              this.manufacturerBarCode.colorNumber
            )
          }
        }
      }

      // 颜色
      getColorSeason({ no: this.colorNo, limit: 99999 }).then((res) => {
        // console.log(res)
        if (res.data.code == 200) {
          this.colorName = res.data.data[0].name
        }
      })

      // 尺码
      getSize({ kind: this.manufacturerBarCode.sizeKindId, limit: 99999 }).then(
        (res) => {
          // console.log(res)
          if (res.data.code == 200) {
            let list = res.data.data
            for (const i of list) {
              if (i.size == this.knSize) {
                this.knSizeList = [i]
                break
              }
            }
          }
        }
      )
    },

    // 保存
    saveNew() {
      if (this.type == '') {
        this.$message({
          type: 'warning',
          message: '类型不能为空'
        })
        return
      }
      // console.log(this.barcodeData)
      var checkMap = {}
      this.barcodeData.forEach((e) => {
        checkMap[e.kindsNumber] = e.sum
      })
      console.log(checkMap)

      var showCodeList = []

      var vipWarehouseCheck = {
        receiptsNumber: this.receiptsNumber,
        customerNo: this.shopNo, //店铺编号
        sequence: this.sequence,
        checkTime: this.checkTime,
        type: this.type == '盘点' ? 0 : 1
        // enteringTime:this.time//录入时间
      }
      let obj = {
        checkMap,
        showCodeList,
        vipWarehouseCheck
      }
      this.$emit('saveNew', obj)
      this.barcodeData = []
      this.howMany = ''
      this.type = ''
      this.sequence = ''

      // if (!this.checkTime1) {
      //   this.$alert('订货日期不能为空', '', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (!this.checkTime2) {
      //   this.$alert('预交日期不能为空', '', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }
      // if (!this.manufacturer) {
      //   this.$alert('厂商不能为空', '', {
      //     confirmButtonText: '确定'
      //   })
      //   return
      // }

      // 补单新增的货号放在kindsNumberNumberMap
      // 原有货号不管有没有修改数量，都将原来数据放在kindsNumberMap

      // let kindsNumberNumberMap = {}

      // let rfidList = []
      // this.barcodeData.forEach(e => {
      //   kindsNumberNumberMap[e.kindsNumber] = Number(e.sum)
      // })

      // let d = {
      //   orderTime: this.checkTime1,
      //   prepayTime: this.checkTime2,
      //   orderSalesSequence : this.receiptsNumber,
      //   manufacturerNo: this.manufacturer,
      //   sequence : this.inputSequence,
      //   remark: this.remark,
      //   isAppend: this.additional ? 1 : 0,
      //   kindsNumberMap: kindsNumberNumberMap
      // }
      // if (this.inputSequence) {
      //   d.enteringTime = this.searchDateWithHour()
      // }

      // console.log(d)
      // // return
      // orderBuild(JSON.stringify(d)).then(res => {
      //   console.log(res)
      //   if (res.data.code == 200) {
      //     this.$message({
      //       message: '保存成功',
      //       type: 'success'
      //     })
      //     let send = {}
      //     send.checkTime1 = this.checkTime1
      //     send.checkTime2 = this.checkTime2
      //     send.manufacturer = this.manufacturer
      //     send.sequence = res.data.data.sequence
      //     // 发送到父组件数据
      //     this.$emit('saveNew', send)

      //     if (res.data.data.errorDate && res.data.data.errorDate.length) {
      //       // 导出一个txt文本
      //       // console.log(String(res.data.data.errorDate))
      //       this.exportRaw(String(res.data.data.errorDate),'errorDate.txt')
      //     }
      //     this.closeNewClerk()
      //   } else {
      //     this.$message.error('保存失败')
      //   }
      // })
    },
    // 继续录入
    continueInput() {
      this.commodityName = ''
      this.onePrice = ''

      // 之前输入货号录入1条
      if (JSON.stringify(this.tmpData) != '{}') {
        // console.log(this.tmpData)
        // console.log(this.barcodeData.length)
        if (!this.barcodeData.length) {
          this.barcodeData.push(this.tmpData)
          this.tmpData = {}
        } else {
          for (const i of this.barcodeData) {
            if (i.kindsNumber == this.tmpData.kindsNumber) {
              i.sum = Number(i.sum) + Number(this.tmpData.sum)
              this.tmpData = {}
              // this.$forceUpdate()
              return
            }
          }
          this.barcodeData.push(this.tmpData)
          this.tmpData = {}
        }
        this.barcode = ''
        return
      }

      // 之前输入款号录入多条

      let knList = []
      console.log(this.codeData, 'hhhh')
      this.codeData.forEach((e) => {
        let c = e.colorNo

        this.sizeList.forEach((f) => {
          if (this.manufacturerBarCode.styleColorSize) {
            // 型尺色

            if (this.manufacturerBarCode.styleColor) {
              // 款号与尺码之间有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}-${f}-${c}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}-${f}${c}`,
                  sum: e[f]
                })
              }
            } else {
              // 款号与尺码之间没有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}${f}-${c}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}${f}${c}`,
                  sum: e[f]
                })
              }
            }
          } else {
            // 型色尺

            if (this.manufacturerBarCode.styleColor) {
              // 款号与颜色之间有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}-${c}-${f}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}-${c}${f}`,
                  sum: e[f]
                })
              }
            } else {
              // 款号与颜色之间没有 -

              if (this.manufacturerBarCode.colorSize) {
                // 色号与尺码之间有 -
                knList.push({
                  kindsNumber: `${this.header}${c}-${f}`,
                  sum: e[f]
                })
              } else {
                // 色号与尺码之间没有 -
                knList.push({
                  kindsNumber: `${this.header}${c}${f}`,
                  sum: e[f]
                })
              }
            }
          }
        })
      })
      // console.log(knList)

      for (const k of knList) {
        for (const l of this.tmpBarcodeData) {
          // console.log(l)
          // console.log(k)
          if (k.kindsNumber == l.kindsNumber) {
            l.sum = k.sum
          }
        }
      }
      // console.log(this.tmpBarcodeData)

      let isExist = 0
      for (const g of this.tmpBarcodeData) {
        if (!Number(g.sum)) continue
        if (!this.barcodeData.length) {
          this.barcodeData.push(g)
          continue
        }
        for (const h of this.barcodeData) {
          if (h.kindsNumber == g.kindsNumber) {
            h.sum = Number(h.sum) + Number(g.sum)
            isExist = 0
            break
          }
          isExist = 1
        }
        if (isExist) {
          this.barcodeData.push(g)
        }
        this.$forceUpdate()
      }

      this.howMany = this.barcodeData.reduce((prev, next) => {
        return Number(prev) + Number(next.sum)
      }, 0)
      this.barcode = ''
      this.header = ''
      this.codeData = []
    },

    // 扫描/输入货号或款号
    barcodeEnter(e) {
      if (this.barcode) {
        if (this.isBarcode) {
          // 扫描货号
          getKindsNumberList({ kindsNumberStr: this.barcode }).then((res) => {
            console.log(res)
            if (res.data.code == 200) {
              this.commodityName = res.data.data.data[0].commodityName
              this.onePrice = res.data.data.data[0].onePrice
              this.tmpData = res.data.data.data[0]
              this.tmpData.sum = this.scanNum
              this.tmpData.onePrice =
                (this.tmpData.discount / 10) * this.tmpData.onePrice
              this.$refs.barcodeInput.focus()
              this.continueInput()
              this.barcode = '' // 条码枪使用  06.09建
              document.getElementById('input').focus() //
            }
          })
        } else {
          // 手输型型号
          getKindsNumberList({ kindsNumberStr: this.barcode }).then((res) => {
            // console.log(res)
            if (res.data.code == 200) {
              if (res.data.data.data.length) {
                this.sizeList = []
                this.$emit('inpNumChange')
                this.commodityName = res.data.data.data[0].commodityName
                this.onePrice = res.data.data.data[0].onePrice
                this.header = res.data.data.data[0].styleNumber
              } else {
                this.$message.info('无此款号数据')
                return
              }
              // 品牌公司查条码规律详情
              getBarCode({
                company: res.data.data.data[0].brandedCompany
              }).then((res) => {
                // console.log(res)
                this.manufacturerBarCode = res.data.data[0]
              })
              // console.log(this.manufacturerBarCode)
              // 输入款号显示中间表和尺码信息   ZZZ-AAS
              res.data.data.data.sort((a, b) => {
                return a.relevanceSize.localeCompare(b.relevanceSize)
              })
              let tmp = res.data.data.data
              this.tmpBarcodeData = tmp
              console.log(tmp, 'temp')

              // 中间表  尺码表头
              this.sizeList = [tmp[0].size]
              let isExistSize = 0
              for (const i of tmp) {
                for (const j of this.sizeList) {
                  if (j == i.size) {
                    isExistSize = 0
                    break
                  }
                  isExistSize = 1
                }
                if (isExistSize) {
                  this.sizeList.push(i.size)
                }
              }
              //
              // 中间表
              let tmpCodeData = [
                { colorNo: tmp[0].colorNo, colorName: tmp[0].colorName }
              ]
              let isExistColor = 0
              for (const i of tmp) {
                for (const j of tmpCodeData) {
                  if (j.colorName == i.colorName) {
                    isExistColor = 0
                    break
                  }
                  isExistColor = 1
                }
                if (isExistColor) {
                  tmpCodeData.push({
                    colorNo: i.colorNo,
                    colorName: i.colorName
                  })
                }
              }
              tmpCodeData.forEach((e) => {
                this.sizeList.forEach((f) => {
                  e[f] = ''
                })
              })
              this.codeData = tmpCodeData
              let codeTable = document.getElementById('codeTable')
              let inputs = codeTable.getElementsByTagName('input')
              // console.log(inputs)
              let int = setInterval(() => {
                clearInterval(int)
                inputs[0].focus()
                inputs[inputs.length - 1].onkeyup = (e) => {
                  if (window.event.keyCode == 13) {
                    this.continueInput()
                    // inputs[inputs.length - 1].onkeyup = () => {}
                  }
                }
              }, 100)
            }
          })
        }
      }
    },

    closePopup() {
      this.showPopup = 'none'
      this.scanNum = this.beforeScanNum
    },

    //  输入回车/失去焦点统计
    //  index 行索引
    //  result 输入内容
    handleInputBlurResult(e, { index, key, result }) {
      e.target.parentNode.parentNode.parentNode.classList.remove('activeCell')
      // let r = /^\+?[1-9][0-9]*$/
      let r = /^(0|[1-9][0-9]*|-[1-9][0-9]*)$/
      if (result != 0) {
        result = result.replace(/\b(0+)/gi, '')
      }
      if (!r.test(result) && result) {
        this.$alert('数量请输入整数', '', {
          confirmButtonText: '确定'
        })
        this.codeData[index][key] = 0
        return
      }
      this.codeData[index][key] = result
    },
    cellClick(row, column, cell, event) {
      cell.classList.add('activeCell')
      let s = this.sibling(cell)
      // console.log(s)
      s.forEach((e) => {
        e.classList.remove('activeCell')
      })
    },
    inpEnter(e) {
      // console.log(e)
      e.target.parentNode.parentNode.parentNode.classList.remove('activeCell')
    }
  },
  mounted() {
    let _this = this
    document.onkeydown = function (event) {
      let e = event || window.event || arguments.callee.caller.arguments[0]
      if (e && e.keyCode == 118) {
        // 按 F7
        // console.log('an f7')
        if (_this.showPopup == 'none') {
          _this.beforeScanNum = _this.scanNum
          _this.showPopup = 'block'
        } else {
          _this.showPopup = 'none'
        }
      }
    }
  }
}
</script>

<style scoped>
/* 新建资料 */
.mask {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  opacity: 0.3;
  z-index: 9;
}
.new_vs {
  position: fixed;
  top: 12%;
  left: 50%;
  transform: translateX(-50%);
  width: 1315px;
  max-height: 800px;
  z-index: 99;
  background-color: white;
  overflow: auto;
}
.new_vs .vs-top {
  height: 40px;
  background-color: #f8f8f8;
  margin-bottom: 10px;
}
.new_vs .vs-top p {
  float: left;
  line-height: 40px;
  padding-left: 20px;
  font-weight: 700;
}
.new_vs .vs-top i {
  float: right;
  line-height: 40px;
  padding: 0 16px;
}

.vs-info {
  padding: 0 20px;
}
.vs-info .info {
  height: 30px;
  margin-bottom: 10px;
}
.vs-info p {
  display: inline-block;
  width: 80px;
  text-align: right;
  margin-right: 15px;
}
.vs-info span {
  line-height: 30px;
}
.colorBox,
.infoBox {
  display: inline;
}

.enterBarcode {
  display: flex;
  height: 60px;
  background-color: #f2f2f2;
  margin: 15px 0;
}

.vs-btn {
  float: right;
  margin: 15px 15px;
}

.popup {
  width: 400px;
  height: 200px;
  border: 2px solid #f4f4f4;
  box-shadow: 0 2px 2px 2px #dbdbdb;
  z-index: 999;
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -100px 0 0 -200px;
  background: white;
  display: block;
}
.popup_t {
  display: flex;
  justify-content: space-between;
  width: 100%;
  height: 40px;
  background: rgb(244, 244, 244);
  padding: 8px 15px;
}
.popup_t p {
  font-weight: 700;
}
.popup_c {
  padding: 8px 15px;
}
.popup_button {
  margin: 5px 0 0 0;
  width: 94%;
  height: 30px;
  padding: 0 10px;
  border: 2px solid #f4f4f4;
  border-radius: 3px;
}
.popup_b {
  margin: 10px 0 0 0;
  padding-left: 230px;
}
</style>

<style>
.new_vs .info .el-input,
.new_vs .info .el-select {
  width: 160px;
}
.new_vs .el-input__inner {
  height: 30px !important;
}
.new_vs .el-input__icon {
  line-height: 30px !important;
}
.vs-info .barcode .el-switch {
  margin: 0 !important;
}

.new_vs .enterBarcode .el-input {
  width: 486px;
  margin: 14px 17px;
}

.new_vs .colorBox .el-input {
  width: 60px;
  margin-right: 10px;
}
.new_vs .colorBox .el-input--suffix {
  width: 90px;
}
</style>
